package cotroller;

import cotroller.event.ChangeGameListener;
import cotroller.event.MovementListener;
import model.Model;
import view.View;

/**
 *
 * @author Andrea
 */
public class Controller {
    
    private Model model;
    private final View view;

    public Controller(Model model, View view) {
        this.model = model;
        this.view = view;
        
        view.addChangeGameListener(new ChangeGameListener(){

            @Override
            public void changeGame(Model model) {
                Controller.this.model = model;
            }
            
        });
        
        view.addMovementListener(new MovementListener(){

            @Override
            public void moveUp() {
                Controller.this.model.moveUp();
            }

            @Override
            public void moveDown() {
                Controller.this.model.moveDown();
            }

            @Override
            public void moveRight() {
                Controller.this.model.moveRight();
            }

            @Override
            public void moveLeft() {
                Controller.this.model.moveLeft();
            }
        
        });
    }

    public void setModel(Model model) {
        this.model = model;
    }
}
